// 云函数 payCallback
const cloud = require('wx-server-sdk')
const rp = require("request-promise")

cloud.init({
	env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
	return await rp({
			url: "https://qingchuang.mguit.com/api/user/wxCallback",
			method: "POST",
			headers: {
				"content-type": "application/json",
			},
			form: {
				'attach': event.outTradeNo.slice(0, -13),
				'transactionId': event.transactionId,
				'type': 2
			},
			json: true,
		})
		.then(function(res) {
			return res
		})
		.catch(function(err) {
			return err
		});
};